﻿using DDD.Domain;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DDD.EFCore
{
    public interface IRepository<TDbContext, TEntiy>
        where TDbContext : EFContext<TDbContext>
        where TEntiy : Entity, IAggregateRoot
       
    {
        IUnitOfWork UnitOfWork { get; }
        TEntiy Add(TEntiy entity);
        Task<TEntiy> AddAsync(TEntiy entity, CancellationToken cancellationToken = default);
        TEntiy Update(TEntiy entity);
        Task<TEntiy> UpdateAsync(TEntiy entity, CancellationToken cancellationToken = default);
        bool Remove(TEntiy entity);
        Task<bool> RemoveAsync(TEntiy entity, CancellationToken cancellationToken = default);
    }

    internal interface IRepository<TDbContext, TEntiy, TKey> : IRepository<TDbContext, TEntiy>
        where TDbContext : EFContext<TDbContext>
        where TEntiy : Entity<TKey>, IAggregateRoot
        //where TKey : IKey
    {
        bool Remove(TKey Id);
        Task<bool> RemoveAsync(TKey Id, CancellationToken cancellationToken = default);
        TEntiy? Get(TKey Id);
        Task<TEntiy?> GetAsync(TKey Id, CancellationToken cancellationToken = default);
    }
}